<template>
	<view class="classify">
		<navbar />
		<tabbar :List="tabbarList" @msg="handlemsg"  @changes="changesitem" :activeItem="activeItem"/>
		<view class="list-conten">
		<list :tabbarList="tabbarList" @changes="changesitem" :activeItem="activeItem"></list>
		</view>
	</view>
</template>

<script>
	export default {
		name: 'classify',
		data() {
			return {
				masg: "123",
				activeItem: 0,
				tabbarList: [],

            shareData: {
                title: '懒七日常分类整理',
                path: '',
                imageUrl: '',
                content: '',
                desc: ''
            }
			}
		},
			//#ifdef MP-WEIXIN
		onShareAppMessage () {
			return {
				title: this.shareData.title,
				path: this.shareData.path,
				imageUrl: this.shareData.imageUrl,
				content: this.shareData.content,
				desc: this.shareData.desc,
				success: res => {
					console.info(res)
				}
			}
		},onShareTimeline: function(res) {
			return {
				title: this.shareData.title,
				path: this.shareData.path,
				imageUrl: this.shareData.imageUrl,
				content: this.shareData.content,
				desc: this.shareData.desc,
				success: res => {
					console.info(res)
				}
			}
		},
		//#endif
		onLoad() {
			// 全局自定义时间接受
			uni.$on("labelChange",(res)=>{
				// console.log(res);
				this.activeItem = 0
				this.tabbarList = []
				this.getLabel()
			})
			
				
			this.getLabel()
		},
		methods: {
			async getLabel() {
				// let tabbarList = await uniCloud.callFunction({ name:"get_label" })
				// console.log(this.$api);
				let tabbarList = await this.$api.get_label()
				await tabbarList.unshift({name:"全部",user:[]})
				// tabbarList.push({name:"全部",user:[]})
				// console.log(tabbarList, 'tabbarListtabbarList')
				this.tabbarList = tabbarList
			},
			handlemsg(data) {
				this.masg = data
			},
			changesitem(index) {
				 this.activeItem = index
				// console.log(this.activeItem);
			}
		}
	}
</script>

<style lang="scss" scoped>
	.classify{
		background-color: #fff;
		display: flex;
		height: 100%;
		flex-direction: column;
		overflow: hidden;
		flex: 1;
		.list-conten{
			height: 100%;
			overflow: hidden;
				// border: 1px solid red;
		}
	}
</style>
